home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / flex_247.zip / flex_247 / MISC / fastwc / wc2.l < prev    next >
Text File  |  1993-07-22  |  348b  |  21 lines

  1. /* Somewhat faster "wc" tool: match more text with each rule */
  2.  
  3. ws    [ \t]
  4. nonws [^ \t\n]
  5. word  {ws}*{nonws}+
  6.  
  7. %%
  8.     int cc = 0, wc = 0, lc = 0;
  9.  
  10. {word}{ws}*    cc += yyleng; ++wc;
  11. {word}{ws}*\n    cc += yyleng; ++wc; ++lc;
  12.  
  13. {ws}+        cc += yyleng;
  14.  
  15. \n+        cc += yyleng; lc += yyleng;
  16.  
  17. <<EOF>>        {
  18.         printf( "%8d %8d %8d\n", lc, wc, cc );
  19.         yyterminate();
  20.         }
  21.